﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RoleEditorView.ascx.cs"
    Inherits="Admin_MemberAdmin_Controls_RoleEditorView" %>
<%@ Register Assembly="Microsoft.Practices.Web.UI.WebControls" Namespace="Microsoft.Practices.Web.UI.WebControls"
    TagPrefix="pp" %>

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $("#<%=FormView1.ClientID%>_InsertButton").css("display", "none");
        $('#addPanel').dialog({
            autoOpen: false,
            width: 300,
            resizable: false,
            buttons: {
                "确认": function() {
                    eval($("#<%=FormView1.ClientID%>_InsertButton").attr("href"));
                    $(this).dialog("close");
                },
                "取消": function() {
                    $(this).dialog("close");
                }
            }
        });
        $("form").append($(".ui-dialog"));
        $("#addNewRole").click(function() {
            $("#addPanel").dialog("open");
        });


    });

    function deleteConfirm(control) {
        var roleName = $(control).attr("title");
        return confirm("是否删除当" + roleName + "前角色")
    }
</script>

<p>
    <input type="button" id="addNewRole" class="iconButton roleAdd" value="添加" />
</p>
<pp:ObjectContainerDataSource ID="ObjectContainerDataSource1" runat="server" DataObjectTypeName="Ornament.MemberShip.Role"
    OnCreating="ObjectContainerDataSource1_Creating" OnDeleted="ObjectContainerDataSource1_Deleted"
    OnSelecting="ObjectContainerDataSource1_Selecting" OnInserted="ObjectContainerDataSource1_Inserted"
    OnUpdated="ObjectContainerDataSource1_Updated" />
<asp:GridView ID="ListView1" runat="server" Caption="角色信息" AllowPaging="True" AutoGenerateColumns="False"
    AllowSorting="True" DataSourceID="ObjectContainerDataSource1" DataKeyNames="Name"
    Width="300px" CssClass="dataGrid">
    <Columns>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Update"
                    Text="确认"></asp:LinkButton>
                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="取消"></asp:LinkButton>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="编辑"></asp:LinkButton>
                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" ToolTip='<%#Eval("Name")%>'
                    CommandName="Delete" Text="删除" OnClientClick="return deleteConfirm(this)"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Name" HeaderText="名称" SortExpression="Name" ReadOnly="True" />
        <asp:BoundField DataField="Comment" HeaderText="备注" SortExpression="Comment"  ControlStyle-CssClass="textbox"/>
    </Columns>
    <EmptyDataTemplate>
        没有数据
    </EmptyDataTemplate>
</asp:GridView>
<div id="addPanel" title="创建新角色">
    <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectContainerDataSource1"
        DefaultMode="Insert">
        <InsertItemTemplate>
            <div>
                <asp:Label ID="Lable1" runat="server" Text="名称:" AssociatedControlID="NameTextBox"></asp:Label>
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'   />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
                    ControlToValidate="NameTextBox" Display="Static"></asp:RequiredFieldValidator>
            </div>
            <div>
                <asp:Label ID="Label2" runat="server" Text="备注" AssociatedControlID="CommentTextBox"></asp:Label>
                <asp:TextBox  ID="CommentTextBox" runat="server" Text='<%# Bind("Comment")%>' />
            </div>
            <div>
                <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="创建" OnClientClick="alert('ok')" />
            </div>
        </InsertItemTemplate>
    </asp:FormView>
</div>
